package com.mall.order.service.impl;

import java.util.List;
import com.mall.common.utils.DateUtils;
import com.mall.order.mapper.OrderItemMapper;
import com.mall.order.model.dto.OrderItemDto;
import com.mall.order.model.vo.OrderItemVo;
import com.mall.order.service.IOrderItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 订单项Service业务层处理
 */
@Service
public class OrderItemServiceImpl implements IOrderItemService
{
    @Resource
    private OrderItemMapper orderItemMapper;

    /**
     * 查询订单项
     */
    @Override
    public OrderItemVo selectOrderItemById(Long id)
    {
        return orderItemMapper.selectOrderItemById(id);
    }

    /**
     * 查询订单项列表
     */
    @Override
    public List<OrderItemVo> selectOrderItemList(OrderItemDto orderItemDto)
    {
        return orderItemMapper.selectOrderItemList(orderItemDto);
    }

    /**
     * 新增订单项
     */
    @Override
    public int insertOrderItem(OrderItemDto orderItemDto)
    {
        orderItemDto.setCreateTime(DateUtils.getNowDate());
        return orderItemMapper.insertOrderItem(orderItemDto);
    }

    /**
     * 修改订单项
     */
    @Override
    public int updateOrderItem(OrderItemDto orderItemDto)
    {
        return orderItemMapper.updateOrderItem(orderItemDto);
    }

    /**
     * 批量删除订单项
     */
    @Override
    public int deleteOrderItemByIds(Long[] ids)
    {
        return orderItemMapper.deleteOrderItemByIds(ids);
    }

    /**
     * 删除订单项信息
     *
     * @param id 订单项主键
     * @return 结果
     */
    @Override
    public int deleteOrderItemById(Long id)
    {
        return orderItemMapper.deleteOrderItemById(id);
    }
}
